{layout name="public/layout" /}

		{include file='yxnavbar'}

<link rel="stylesheet" href="{$_G['URL']['APP_CSS']}back.css">
	<style type="text/css">
	.order-detail-info>div{margin-bottom:10px; padding-left:15px;}
	.page-trade-order h4{font-size:14px; font-weight:700;}
	.page-trade-order .form-group{margin-bottom:0;}
	.page-trade-order .form-group .control-label{font-weight:normal; color:#999;}
	.page-trade-order .order-infos{border-right:1px solid #ddd;}
	.page-trade-order .parting-line{height:1px;border-top:1px dashed #e5e5e5; margin:3px 0;}
	.page-trade-order .order-state{padding-left:40px; position:relative; margin:20px 0 40px;}
	.page-trade-order .order-state>span{color:#07d; position:absolute; left:0; top:5px; font-size:25px; display:inline-block; width:30px; height:30px; border:1px solid #07d; border-radius:30px; text-align:center; line-height:30px;}
	#close-order ul li{padding:5px 15px; cursor:pointer;}
	#close-order ul li:hover{background:#eee;}
	.fix a.js-order-edit-address{display:none; color:red;}
	.fix:hover a.js-order-edit-address{display:inline;}
	.page-trade-order .col-sm-9{word-break: break-word; overflow:hidden;}
	.table-log>tbody>tr>td{border-top:none;}
</style>
<script type="text/javascript">
function submitForm(){
    var form = document.getElementById("myform");
    form.submit();
}
</script>
<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading">筛选 共{$total}条</div>
		<div class="panel-body">
			<form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="op" value="mingxi" />
				<input type="hidden" name="status" value="{$status}" />
				<input type="hidden" name="type" value="{$type}" />
				<input type="hidden" name="isfinish" value="{$isfinish}" />
<!-- 				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">未核销</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						 <select class="form-control" name="shopid1">
                        <option value="" >全部</option>
                   		{loop $shoplist1 $row}
			         		<option value="{$row['id']}" {if $shopid1 == $row['id'] }selected="selected"{/if}>{$row['name']}【{$row['num']}】</option>
			       		{/loop}
			     		 </select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">已核销</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						 <select class="form-control" name="shopid2">
                        <option value="" >全部</option>
                   		{loop $shoplist2 $row}
			         		<option value="{$row['id']}" {if $shopid2 == $row['id'] }selected="selected"{/if}>{$row['name']}【{$row['num']}】</option>
			       		{/loop}
			     		 </select>
					</div>
				</div> -->
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">按员工</label>
					{if !empty($shoplist)}
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						 <select class="form-control" name="shopid">
                        <option value="" >全部商家</option>
                   		{loop $shoplist $row}
			         		<option value="{$row['id']}" {if $shopid == $row['id'] }selected="selected"{/if}>{$row['name']}</option>
			       		{/loop}
			     		 </select>
					</div>
					{/if}
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						 <select class="form-control" name="workerid">
                        <option value="" >全部员工</option>
                   		{loop $wlist $row}
			         		<option value="{$row['uid']}" {if $workerid == $row['uid'] }selected="selected"{/if}>{if $system['ruanjian']==3}{$row['companyname']}-{/if}{$row['teamname']}-{$row['username']}</option>
			       		{/loop}
			     		 </select>
					</div>
					<div class="col-sm-5 col-lg-5 col-md-5 col-xs-5">
					</div>
					{if count($themelist)>1}
						<div class="col-sm-3 col-xs-3 col-md-3">
							 <select onchange="submitForm();" class="form-control" name="themeid">
	                   		{loop $themelist $row}
				         		<option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
				       		{/loop}
				     		 </select>
			 			</div>
					{else}
						<input type="hidden" name="themeid" value="{$themeid}" /> 
					{/if}
				</div>
				<div class="form-group clearfix">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">核销时间</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						{php echo view_form_field_daterange('createtime', array('start'=>date('Y-m-d H:i:s',$starttime),'end'=>date('Y-m-d H:i:s',$endtime)), true);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						<input class="form-control" name="keyword" placeholder="可输入昵称、用户名、手机号" type="text" value="{$_P['keyword']}">
					</div>
					<div class="col-sm-1 col-lg-1 col-md-1 col-xs-6">
						<button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
						<input type="hidden" name="__token__" value="{$Request.token}"/>
					</div>
					<div class="col-sm-2 col-lg-2 col-md-2 col-xs-6">
						<input class="btn btn-info" type="submit" name="export_submit" id="export_submit" value="导出核销明细">
					</div>
					<div class="col-sm-2 col-lg-2 col-md-2 col-xs-6">
						<a href="{php echo createWebUrl($do, array('op2' => 'export_submit','themeid'=>$themeid));}" class="btn btn-default"  data-toggle="tooltip" data-placement="top">导出核销总表</a>
                    </div>
				</div>
			</form>
		</div>
	</div>

	{if $op == 'display'}
		<div class="panel panel-default">
			<div class="panel-body table-responsive" style="overflow:inherit">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th>定单号</th>
							<th>微信</th>
							<th>用户</th>
							{if (empty($shoplist)) }
							<th><br>已核销{$gsum}</th>
							{else}
							{loop $shoplist2 $row}
							<th >{php echo mb_substr($row['name'],0,6,'utf-8');}<br>已核销{$row['num']}</th>
							{/loop}
							{/if}
							<th style="width:85px; text-align:right;">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $row}
						<tr>
							<td><b>{php echo $row['id']+9000;}</b></td>
							<td  style="font-size: 10px;max-width: 100px;">
								<img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;">
								<br>
								{$row['nickname']}
							</td>
							<td>
								{$row['username']}<br>
								{$row['mobile']}
							</td>
							{if (empty($shoplist)) }
								{if !empty($row['shop'.$shopindex]['hxtime'])}
									<th>{php echo $row['shop'.$shopindex]['workername'];}<br>{php echo str_replace(" ","<br>",$row['shop'.$shopindex]['hxtime']);}</th>
								{else}
									<th>
									<a href="{php echo createWebUrl($do, array('op' => 'hexiao','themeid'=>$themeid, 'uid' => $row['uid'], 'shopid' =>0));}" onclick="if(!confirm('手工核销，确定吗')) return false;" title="手工核销" ><span class="label label-warning">未核销</span></a>
									</th>
								{/if}
							{else}
							{loop $shoplist $shopindex $shoprow}
								{if !empty($row['shop'.$shopindex]['hxtime'])}
									<th>{php echo $row['shop'.$shopindex]['workername'];}<br>{php echo str_replace(" ","<br>",$row['shop'.$shopindex]['hxtime']);}</th>
								{else}
									<th>
									<a href="{php echo createWebUrl($do, array('op' => 'hexiao','themeid'=>$themeid, 'uid' => $row['uid'], 'shopid' => $shoprow['id']));}" onclick="if(!confirm('手工核销，确定吗')) return false;" title="手工核销" ><span class="label label-warning">未核销</span></a>
									</th>
								{/if}
							{/loop}
							{/if}
							<td style="text-align:right; overflow:visible;">
								<div class="btn-group">
									<a href="{php echo createWebUrl('record', array('op' => 'display','themeid'=>$themeid, 'keyword' => $row['mobile']));}"  class="btn btn-success btn-sm" title="查看定单" data-toggle="tooltip" data-placement="top"><i class="fa fa-eye">定单</i></a>	
                                </div>
							</td>
						</tr>
						{/loop}
					
					</tbody>
				</table>
			</div>
		</div>
		{else}
		<div class="panel panel-default">
			<div class="panel-body table-responsive" style="overflow:inherit">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th>定单号</th>
							<th>微信</th>
							<th>用户</th>
							<th>核销人</th>
							<th>核销时间</th>
							<th style="width:85px; text-align:right;">操作</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $row}
						<tr>
							<td><b>{php echo $row['id']+9000;}</b></td>
							<td  style="font-size: 10px;max-width: 100px;">
								<img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;">
								<br>
								{$row['nickname']}
							</td>
							<td>
								{$row['username']}<br>
								{$row['mobile']}
							</td>
							<td>{$row['workername']}<br>{$row['teamname']}<br>{php echo mb_substr($row['companyname'],0,6,'utf-8');}</td>
							<td>{$row['hexiaotime']}</td>
							<td style="text-align:right; overflow:visible;">
								<div class="btn-group">
									<a href="{php echo createWebUrl('record', array('op' => 'display','themeid'=>$themeid, 'keyword' => $row['mobile']));}"  class="btn btn-success btn-sm" title="查看定单" data-toggle="tooltip" data-placement="top"><i class="fa fa-eye">定单</i></a>	
                                </div>
							</td>
						</tr>
						{/loop}
					
					</tbody>
				</table>
			</div>
		</div>
		{/if}
		{$pager}
</div>
<script type="text/javascript">
	$(function(){
		$('.app-preview').click(function(){
			return false;
		});
		require(['underscore', 'bootstrap.switch'], function() {
			$(":checkbox[name='isluck[]']").bootstrapSwitch();
			$(":checkbox[name='isluck[]']").on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var isluck = this.checked ? 1 : 0;
				$.post("{php echo createWebUrl($do, array('op' => 'isluck','themeid'=>$themeid));}", {isluck:isluck,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
			$(":checkbox[name='status[]']").bootstrapSwitch();
			$(":checkbox[name='status[]']").on('switchChange.bootstrapSwitch', function(e, state){
				$this = $(this);
				var id = $(this).data('id');
				var status = this.checked ? 2 : 1;
				$.post("{php echo createWebUrl($do, array('op' => 'status','themeid'=>$themeid));}", {status:status,id: id}, function(resp){
					resp = $.parseJSON(resp);
					if(resp.message.errno != 0) {
						layer.msg('操作失败, 请稍后重试');
					} else {
						layer.msg('操作成功');
					}
				});
			});
			
			
			
			
		});
	});
</script>
<script type="text/javascript">
// require(['util'], function(u){

// 	$('#selectall').click(function(){
// 		$('#form-order :checkbox').prop('checked', $(this).prop('checked'));
// 	});

// 	$('.btn-order').click(function(){
// 		if($('#form-order :checkbox:checked').length == 0) {
// 			u.message('请选择定单', '', 'error');
// 			return false;
// 		}
// 		if(!confirm('确定修改定单的状态吗')) {
// 			return false;
// 		}
// 		$('#form-order #status').val($(this).data('id'));
// 		$('#form-order #type').val($(this).data('type'));
// 		$('#form-order').submit();
// 		return false;
// 	});

// 	$('.btn-cancel').click(function(e){
// 		var pay = $(this).data('pay');
// 		var pay_type = $(this).data('pay-type');
// 		var tip = '确定取消定单吗';
// 		if(pay == 1) {
// 			if(pay_type == 'cash') {
// 				var tip = '该定单为现金支付, 取消定单需要商家自己处理退款, 确定取消定单吗';
// 			} else if(pay_type != 'delivery') {
// 				var tip = '该定单为线上支付, 取消定单将发起退款流程, 确定取消定单吗';
// 			}
// 		}
// 		if(!confirm(tip)) {
// 			e.preventDefault();
// 		}
// 		return true;
// 	});


// });
</script>
